/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AddExhibitor.java
 *
 * Created on Mar 17, 2011, 2:59:39 PM
 */

package GUI;

import Business.ExhibitorManage;
import Entities.Exhibitor;
import java.sql.Date;
//import java.text.SimpleDateFormat;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author Nhit
 */
public class AddExhibitor extends javax.swing.JFrame {
    private int id;
    /** Creates new form AddExhibitor */
    public AddExhibitor(int id, String name) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(AddExhibitor.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(AddExhibitor.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(AddExhibitor.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(AddExhibitor.class.getName()).log(Level.SEVERE, null, ex);
        }
        initComponents();
        this.setId(id);
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null,name, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14)));
        fillData(id);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        txtFirstName = new javax.swing.JTextField();
        txtOrganization = new javax.swing.JTextField();
        txtCity = new javax.swing.JTextField();
        txtCountry = new javax.swing.JTextField();
        txtIdentiyCard = new javax.swing.JTextField();
        cbbSex = new javax.swing.JComboBox();
        txtLastName = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        txaAddress = new javax.swing.JTextArea();
        txtEmail = new javax.swing.JTextField();
        txtPhone = new javax.swing.JTextField();
        cbbStatus = new javax.swing.JComboBox();
        txtAccountBank = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        lblFirstName = new javax.swing.JLabel();
        lblLastName = new javax.swing.JLabel();
        lblSex = new javax.swing.JLabel();
        lblEmail = new javax.swing.JLabel();
        lblPhoneNumber = new javax.swing.JLabel();
        lblOrganization = new javax.swing.JLabel();
        lblAddress = new javax.swing.JLabel();
        lblCity = new javax.swing.JLabel();
        lblCountry = new javax.swing.JLabel();
        lblIdentityCard = new javax.swing.JLabel();
        lblAccountBank = new javax.swing.JLabel();
        lblBankName = new javax.swing.JLabel();
        lblMsAddress = new javax.swing.JLabel();
        lblStatus = new javax.swing.JLabel();
        txtBankName = new javax.swing.JTextField();
        lblMsFName = new javax.swing.JLabel();
        lblMsLastName = new javax.swing.JLabel();
        lblMsEmail = new javax.swing.JLabel();
        lblMsPhone = new javax.swing.JLabel();
        lblMsCity = new javax.swing.JLabel();
        lblMsCountry = new javax.swing.JLabel();
        lblMsIdentiy = new javax.swing.JLabel();
        lblMsAccountbank = new javax.swing.JLabel();
        lblMsBankName = new javax.swing.JLabel();
        btnSave = new javax.swing.JButton();
        btnReset = new javax.swing.JButton();
        btnCancel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Exhibitor Details", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14))); // NOI18N

        txtCountry.setPreferredSize(new java.awt.Dimension(20, 20));

        txtIdentiyCard.setPreferredSize(new java.awt.Dimension(20, 20));

        cbbSex.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Male", "FeMale", "Other" }));

        txaAddress.setColumns(20);
        txaAddress.setRows(5);
        jScrollPane1.setViewportView(txaAddress);

        cbbStatus.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Nomarl", "Block" }));

        lblFirstName.setText("First Name");

        lblLastName.setText("Last Name");

        lblSex.setText("Sex");

        lblEmail.setText("Email");

        lblPhoneNumber.setText("Phone Number");

        lblOrganization.setText("Organization name");

        lblAddress.setText("Address");

        lblCity.setText("City");

        lblCountry.setText("Country/Region");

        lblIdentityCard.setText("Identity Card Number");

        lblAccountBank.setText("Bank Account Number");

        lblBankName.setText("Bank name");

        lblMsAddress.setForeground(new java.awt.Color(204, 51, 0));
        lblMsAddress.setText(" ");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblFirstName)
                    .addComponent(lblLastName)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(lblMsAddress, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lblAddress, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap(55, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(lblOrganization, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblPhoneNumber)
                .addContainerGap(36, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblEmail)
                .addContainerGap(82, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblSex)
                .addContainerGap(88, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblIdentityCard)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblCountry)
                .addContainerGap(30, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblCity)
                .addContainerGap(87, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblAccountBank)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblBankName)
                .addContainerGap(54, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(lblFirstName)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lblLastName)
                .addGap(18, 18, 18)
                .addComponent(lblSex)
                .addGap(11, 11, 11)
                .addComponent(lblEmail)
                .addGap(18, 18, 18)
                .addComponent(lblPhoneNumber)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lblOrganization)
                .addGap(18, 18, 18)
                .addComponent(lblAddress)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblMsAddress)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                .addComponent(lblCity)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lblCountry)
                .addGap(18, 18, 18)
                .addComponent(lblIdentityCard)
                .addGap(18, 18, 18)
                .addComponent(lblAccountBank)
                .addGap(18, 18, 18)
                .addComponent(lblBankName)
                .addGap(9, 9, 9))
        );

        lblStatus.setText(" ");

        lblMsFName.setForeground(new java.awt.Color(204, 51, 0));
        lblMsFName.setText(" ");

        lblMsLastName.setForeground(new java.awt.Color(204, 51, 0));
        lblMsLastName.setText(" ");

        lblMsEmail.setForeground(new java.awt.Color(204, 51, 0));
        lblMsEmail.setText(" ");

        lblMsPhone.setForeground(new java.awt.Color(153, 51, 0));
        lblMsPhone.setText(" ");

        lblMsCity.setForeground(new java.awt.Color(204, 51, 0));
        lblMsCity.setText(" ");

        lblMsCountry.setForeground(new java.awt.Color(204, 51, 0));
        lblMsCountry.setText(" ");

        lblMsIdentiy.setForeground(new java.awt.Color(204, 51, 0));
        lblMsIdentiy.setText(" ");

        lblMsAccountbank.setForeground(new java.awt.Color(204, 51, 0));
        lblMsAccountbank.setText(" ");

        lblMsBankName.setForeground(new java.awt.Color(204, 51, 0));
        lblMsBankName.setText(" ");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE)
                    .addComponent(txtOrganization, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(txtAccountBank, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtCity, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtCountry, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtIdentiyCard, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblMsCountry, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                            .addComponent(lblMsCity, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                            .addComponent(lblMsIdentiy, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)
                            .addComponent(lblMsAccountbank, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE)))
                    .addComponent(txtBankName, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(txtPhone, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(txtEmail, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(txtLastName, javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(txtFirstName, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE))
                            .addComponent(cbbSex, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(lblMsLastName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(lblMsFName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(lblMsEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addComponent(lblStatus, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(cbbStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(lblMsPhone, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE)))
                    .addComponent(lblMsBankName, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtFirstName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblMsFName))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtLastName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblMsLastName))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cbbSex, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cbbStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblStatus))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblMsEmail))
                        .addGap(11, 11, 11)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblMsPhone))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtOrganization, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(11, 11, 11)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtCity, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblMsCity))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtCountry, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblMsCountry))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtIdentiyCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblMsIdentiy))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtAccountBank, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblMsAccountbank))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtBankName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblMsBankName))
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(19, Short.MAX_VALUE))
        );

        btnSave.setText("Save");
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });

        btnReset.setText("Reset");
        btnReset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnResetActionPerformed(evt);
            }
        });

        btnCancel.setText("Cancel");
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(149, 149, 149)
                        .addComponent(btnSave)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnReset)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnCancel))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnSave)
                    .addComponent(btnReset)
                    .addComponent(btnCancel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
        // TODO add your handling code here:
        this.setVisible(false);
    }//GEN-LAST:event_btnCancelActionPerformed

    private void btnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnResetActionPerformed
        // TODO add your handling code here:
        txtCity.setText(null);
        txtCountry.setText(null);
        txtEmail.setText(null);
        txtFirstName.setText(null);
        txtIdentiyCard.setText(null);
        txtLastName.setText(null);
        txtOrganization.setText(null);
        txtPhone.setText(null);
        txaAddress.setText(null);
        cbbSex.setSelectedIndex(1);
    }//GEN-LAST:event_btnResetActionPerformed

    private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
        if(checkForm()){
            //Lay gio he thong
            Date todayD=new Date(System.currentTimeMillis()); 

            //Khai bao dinh dang ngay thang
           // SimpleDateFormat dayFormat= new SimpleDateFormat("dd/MM/yyyy"); 

            //parse ngay thang sang dinh dang va chuyen thanh string.
            //String todayS=dayFormat.format(todayD.getTime());  

            Exhibitor objExhibitor = new Exhibitor(id,txtFirstName.getText(),txtLastName.getText(),
                    cbbSex.getSelectedItem().toString(),txtEmail.getText(),txtPhone.getText(),
                    txtOrganization.getText(),txaAddress.getText(),txtCity.getText(),txtCountry.getText(),
                    txtAccountBank.getText(),txtBankName.getText(),cbbStatus.getSelectedIndex(),txtIdentiyCard.getText(),
                    
                    todayD, todayD);
            ExhibitorManage objSave = new ExhibitorManage();
            if(id == 0){
               if(objSave.add(objExhibitor)){
                    JOptionPane.showMessageDialog(rootPane, "Add new succfully");
                    this.setVisible(false);
                }else{
                    JOptionPane.showMessageDialog(rootPane, "Add error");
                }
            } else{
                if(objSave.update(objExhibitor)){
                    JOptionPane.showMessageDialog(rootPane, "Update succfully");
                    this.setVisible(false);
                }else{
                    JOptionPane.showMessageDialog(rootPane, "Update error");
                }
            }
            
           //JOptionPane.showMessageDialog(rootPane, "De nghi dien het vao em oi","Warring", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_btnSaveActionPerformed
    private boolean isValidEmailAddress(String emailAddress){
       String  expression="^[\\w\\-]([\\.\\w])+[\\w]+@([\\w\\-]+\\.)+[A-Z]{2,4}$";
       CharSequence inputStr = emailAddress;
       Pattern pattern = Pattern.compile(expression,Pattern.CASE_INSENSITIVE);
       Matcher matcher = pattern.matcher(inputStr);
       return matcher.matches();
    }
    private boolean isValidNumber(String number){
       String  expression="[0-9]{6,20}";
       CharSequence inputStr = number;
       Pattern pattern = Pattern.compile(expression,Pattern.CASE_INSENSITIVE);
       Matcher matcher = pattern.matcher(inputStr);
       return matcher.matches();
    }
    private boolean checkForm(){
        boolean flag = false;
        if(txtFirstName.getText().length() <1){
            lblMsFName.setText("*");
            txtFirstName.requestFocus();
            flag = false;
        }else if(txtAccountBank.getText().length() <1){
            lblMsAccountbank.setText("*");
            txtAccountBank.requestFocus();
            flag = false;
        }else if(txtBankName.getText().length() <1){
            lblMsBankName.setText("*");
            txtBankName.requestFocus();
            flag = false;
        }else if(txtCity.getText().length() <1 ){
            lblMsCity.setText("*");
            txtCity.requestFocus();
            flag = false;
        }else if(txtCountry.getText().length() <1 ){
            lblMsCountry.setText("*");
            txtCountry.requestFocus();
            flag = false;
        }else if(txtIdentiyCard.getText().length() <1 ){
            lblMsIdentiy.setText("*");
            txtIdentiyCard.requestFocus();
            flag = false;
        }else if(txtLastName.getText().length() <1 ){
            lblMsLastName.setText("*");
            txtLastName.requestFocus();
            flag = false;
        }else if(txtPhone.getText().length() <6 ){
            lblMsPhone.setText("*");
            txtPhone.requestFocus();
            flag = false;
        }else if(!isValidEmailAddress(txtEmail.getText())){
            lblMsEmail.setText("Invaild (examp@gmail.com)");
            txtEmail.requestFocus();
            flag = false;
        }else if(!isValidNumber(txtPhone.getText()) ){
            lblMsPhone.setText("Must be a number");
            txtPhone.requestFocus();
            flag = false;
        }
        else if(!isValidNumber(txtIdentiyCard.getText()) ){
            lblMsIdentiy.setText("Must be a number");
            txtIdentiyCard.requestFocus();
            flag = false;
        }else if(!isValidNumber(txtAccountBank.getText())){
            lblMsAccountbank.setText("Must be a number");
            txtAccountBank.requestFocus();
            flag = false;
        }else if (txaAddress.getText().length() < 10){
            lblMsAddress.setText("*");
            txaAddress.requestFocus();
            flag = false;
        }else{
            return flag = true;
        }
        return flag;
    }
    /**
    * @param args the command line arguments
    */
    /*public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new AddExhibitor().setVisible(true);
            }
        });
    }*/
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }
    private void fillData(int id){
        if(id !=0){
            ExhibitorManage objExhibitorManage = new ExhibitorManage();
            Exhibitor objExhibitor = objExhibitorManage.getExhibitorById(id);
            txtFirstName.setText(objExhibitor.getFirstName());
            txtLastName.setText(objExhibitor.getLastName());
            txtAccountBank.setText(objExhibitor.getAccountBank().toString());
            txtBankName.setText(objExhibitor.getBankName());
            txtCity.setText(objExhibitor.getCity());
            txtCountry.setText(objExhibitor.getCountry());
            txtEmail.setText(objExhibitor.getEmail());
            txtIdentiyCard.setText(objExhibitor.getIdentityCardNumber());
            txtOrganization.setText(objExhibitor.getOrganizationName());
            txaAddress.setText(objExhibitor.getAddress());
            cbbSex.setSelectedItem(objExhibitor.getSex());
            cbbStatus.setSelectedIndex(objExhibitor.getStatus());
            
            //txtCity.setText(objExhibitor.get);
        }
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnReset;
    private javax.swing.JButton btnSave;
    private javax.swing.JComboBox cbbSex;
    private javax.swing.JComboBox cbbStatus;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblAccountBank;
    private javax.swing.JLabel lblAddress;
    private javax.swing.JLabel lblBankName;
    private javax.swing.JLabel lblCity;
    private javax.swing.JLabel lblCountry;
    private javax.swing.JLabel lblEmail;
    private javax.swing.JLabel lblFirstName;
    private javax.swing.JLabel lblIdentityCard;
    private javax.swing.JLabel lblLastName;
    private javax.swing.JLabel lblMsAccountbank;
    private javax.swing.JLabel lblMsAddress;
    private javax.swing.JLabel lblMsBankName;
    private javax.swing.JLabel lblMsCity;
    private javax.swing.JLabel lblMsCountry;
    private javax.swing.JLabel lblMsEmail;
    private javax.swing.JLabel lblMsFName;
    private javax.swing.JLabel lblMsIdentiy;
    private javax.swing.JLabel lblMsLastName;
    private javax.swing.JLabel lblMsPhone;
    private javax.swing.JLabel lblOrganization;
    private javax.swing.JLabel lblPhoneNumber;
    private javax.swing.JLabel lblSex;
    private javax.swing.JLabel lblStatus;
    private javax.swing.JTextArea txaAddress;
    private javax.swing.JTextField txtAccountBank;
    private javax.swing.JTextField txtBankName;
    private javax.swing.JTextField txtCity;
    private javax.swing.JTextField txtCountry;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtFirstName;
    private javax.swing.JTextField txtIdentiyCard;
    private javax.swing.JTextField txtLastName;
    private javax.swing.JTextField txtOrganization;
    private javax.swing.JTextField txtPhone;
    // End of variables declaration//GEN-END:variables
    //Exhibitor objExhi
    /**
     * @return the id
     */
    


}
